#输出九九乘法表
#for…in

#左下三角
for j in range(1,10):
    for i in range(1,j+1):
        print("{}*{}={:<4}".format(i,j,i*j),end=" ")
    print("")
print("="*86)
#左上三角
for j in range(9,0,-1):
    for i in range(1,j+1):
        print("{}*{}={:<4}".format(i,j,i*j),end=" ")
    print("")
print("="*86)


#右下三角
for i in range(1,10):
    for k in range(1,10-i):
        print(end="        ")
    for j in range(1,i+1):
        product = i*j
        print("%d*%d=%2d" % (i,j,product),end="  ")
    print(" ")
print("="*86)
#右上三角
for i in range(1,10):
    for k in range(1,i):
        print(end="        ")
    for j in range(i,10):
        product = i*j
        print("%d*%d=%2d" % (i,j,product),end="  ")
    print(" ")
print("="*86)

#用while循环输出九九乘法表
#左下三角
j = 1
while j<=9:
    i = 1
    while i<=j:
        print("{}*{}={:<4}".format(i, j, i * j), end=" ")
        i+=1
    print(" ")
    j+=1
print("=" * 86)
#左上三角
j = 9
while j>=1:
    i = 1
    while i<=j:
        print("{}*{}={:<4}".format(i, j, i * j), end=" ")
        i+=1
    print(" ")
    j-=1
print("=" * 86)
#右下三角
i = 1
while i<=9:
    k = 1
    while k<=9-i:  #判断应该用多少个空格来填充前面的空白
        print(' ',end = '         ')
        k += 1
    j = 1
    while j <= i:
        print("%d*%d=%-2d"%(i,j,i*j),end = '    ')
        j += 1
    print()
    i += 1
print("=" * 86)
#右上三角
i = 9
while i>=1:
    k = 1
    while k<=9-i:  #判断应该用多少个空格来填充前面的空白
        print(' ',end = '         ')
        k += 1
    j = 1
    while j <= i:
        print("%d*%d=%-2d"%(i,j,i*j),end = '    ')
        j += 1
    print()
    i -= 1
